//
// File: myinterp1.cpp
//
// MATLAB Coder version            : 5.4
// C/C++ source code generated on  : 20-Mar-2025 10:43:11
//

// Include Files
#include "myinterp1.h"
#include "interp1.h"
#include "myinterp1_data.h"
#include "myinterp1_initialize.h"
#include "rt_nonfinite.h"
#include "coder_array.h"
#include <cmath>

// Function Definitions
//
// Arguments    : const coder::array<double, 2U> &t
//                const coder::array<double, 2U> &y
//                const coder::array<double, 2U> &t2
//                coder::array<double, 2U> &y2
// Return Type  : void
//
void myinterp1(const coder::array<double, 2U> &t,
               const coder::array<double, 2U> &y,
               const coder::array<double, 2U> &t2, coder::array<double, 2U> &y2)
{
  coder::array<double, 2U> b_y;
  coder::array<double, 2U> x;
  int i;
  int nd2;
  int nx;
  boolean_T b;
  if (!isInitialized_myinterp1) {
    myinterp1_initialize();
  }
  b_y.set_size(1, y.size(1));
  nd2 = y.size(1);
  for (i = 0; i < nd2; i++) {
    b_y[i] = y[i];
  }
  x.set_size(1, t.size(1));
  nd2 = t.size(1);
  for (i = 0; i < nd2; i++) {
    x[i] = t[i];
  }
  nx = t.size(1) - 1;
  y2.set_size(1, t2.size(1));
  nd2 = t2.size(1);
  for (i = 0; i < nd2; i++) {
    y2[i] = 0.0;
  }
  b = (t2.size(1) == 0);
  if (!b) {
    nd2 = 0;
    int exitg1;
    do {
      exitg1 = 0;
      if (nd2 <= nx) {
        if (std::isnan(t[nd2])) {
          exitg1 = 1;
        } else {
          nd2++;
        }
      } else {
        if (t[1] < t[0]) {
          double xtmp;
          i = (nx + 1) >> 1;
          for (int b_j1{0}; b_j1 < i; b_j1++) {
            xtmp = x[b_j1];
            nd2 = nx - b_j1;
            x[b_j1] = x[nd2];
            x[nd2] = xtmp;
          }
          nd2 = y.size(1) >> 1;
          for (int b_j1{0}; b_j1 < nd2; b_j1++) {
            nx = (y.size(1) - b_j1) - 1;
            xtmp = b_y[b_j1];
            b_y[b_j1] = b_y[nx];
            b_y[nx] = xtmp;
          }
        }
        coder::interp1SplineOrPCHIP(b_y, t2, y2, x);
        exitg1 = 1;
      }
    } while (exitg1 == 0);
  }
}

//
// File trailer for myinterp1.cpp
//
// [EOF]
//
